package com.baixiaowen.xiaoaointerview.并发提升篇.volatile关键字实现原理;

import java.util.concurrent.TimeUnit;

public class ReOrdering {

    static volatile int a = 0;

    public static void main(String[] args) {
        Runnable r1 = () -> {
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            a = 10000;
            System.err.println("set a");
        };

        Runnable r2 = () -> {
            while (a < 100) {

            }

            System.err.println("end: " + a);
        };

        new Thread(r1).start();
        new Thread(r2).start();
    }

}
